------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
      name:  <unnamed>
       log:  /Users/sascha/Dropbox/suicide/RESTAT_replication/gsoep-suicide-data-2003-restat.log
  log type:  text
 opened on:  22 Jul 2017, 11:35:20
r; t=0.00 11:35:20

. display "This version: $S_DATE $S_TIME";
This version: 22 Jul 2017 11:35:20
r; t=0.00 11:35:20

. global rootgsoep "/Users/sascha/work/gsoep/GSOEP26/";
r; t=0.00 11:35:20

. use persnr psample using "$rootgsoep/ppfad.dta";
(PPFAD: 09/10/10 10:14:13-634 DB09)
r; t=0.05 11:35:20

. /***********************************************************************************************************/
> /* keep West Germans (including foreigners), East Germans (sample 3) and refreshment samples 1998 and 2000 */
> /***********************************************************************************************************/
> 
> tab psample;

                   Stichprobenart |      Freq.     Percent        Cum.
----------------------------------+-----------------------------------
            [1] A Deutsche (West) |     17,765       26.84       26.84
          [2] B Auslaender (West) |      7,396       11.17       38.01
             [3] C Deutsche (Ost) |      8,524       12.88       50.89
  [4] D Zuwanderer (West) 1984-93 |      2,192        3.31       54.20
            [5] E Ergaenzung 1998 |      2,872        4.34       58.54
            [6] F Ergaenzung 2000 |     16,529       24.97       83.52
[7] G Hocheinkommensbezieher 2002 |      3,798        5.74       89.25
            [8] H Ergaenzung 2006 |      3,575        5.40       94.65
        [9] I Incentivierung 2009 |      3,538        5.35      100.00
----------------------------------+-----------------------------------
                            Total |     66,189      100.00
r; t=0.02 11:35:20

. /*                 Stichprobenart |      Freq.     Percent        Cum.
> ----------------------------------+-----------------------------------
>             [1] A Deutsche (West) |      5,480       24.26       24.26
>           [2] B Auslaender (West) |      1,519        6.72       30.98
>              [3] C Deutsche (Ost) |      3,453       15.28       46.26
>   [4] D Zuwanderer (West) 1984-93 |        789        3.49       49.76
>             [5] E Ergaenzung 1998 |      1,332        5.90       55.65
>             [6] F Ergaenzung 2000 |      8,006       35.44       91.09
> [7] G Hocheinkommensbezieher 2002 |      2,013        8.91      100.00
> ----------------------------------+-----------------------------------
>                             Total |     22,592      100.00
> */
> 
> keep if psample==1 | psample==2 | psample==3 | psample==4 | psample==5 | psample==6;
(10,911 observations deleted)
r; t=0.02 11:35:20

. sort persnr;
r; t=0.05 11:35:20

. save my_ppfad.dta, replace;
file my_ppfad.dta saved
r; t=0.00 11:35:20

. /********************************/
> /* information from GSOEP files */
> /********************************/
> 
> /* 2003 */
> use persnr
>         tp0901 /* religious orientation */
>         tp1401 /* Essen oder trinken gehen (Café, Kneipe, Restaurant) */
>         tp1402 /* Besuche Nachbarn,Freunde */
>         tp1403 /* Besuche Familie,Verwandte */
>         tp1407 /* Kirchgang, Besuch religioeser Veranstaltungen */
>         using $rootgsoep/tp;
(TP: 09/10/10 10:14:13-634 DB09)
r; t=0.06 11:35:20

. rename tp0901 relig;
r; t=0.01 11:35:20

. label define religlbl 
> 1 "[1] catholic"
> 2 "[2] protestant"
> 3 "[3] other christian denomination"
> 4 "[4] other denomination"
> 5 "[5] no denomination or religion";
r; t=0.00 11:35:20

. label values relig religlbl;
r; t=0.00 11:35:20

. /* TP0901 
> Do you belong to a church or religious community?
> If yes, are you 
> catholic ___
> evangelical ___
> member of another Christian community ___
> member of another religious community ___ ____ TP0902 Please indicate
> No, nondenominational ___  
> . tab tp0901
> 
>                   Kirche, Religion |      Freq.     Percent        Cum.
> -----------------------------------+-----------------------------------
>                    -1 keine Angabe |        146        0.65        0.65
>                       1 katholisch |      6,698       29.62       30.27
>                      2 evangelisch |      7,525       33.28       63.55
> 3 Andere christl. Rel.gemeinschaft |        524        2.32       65.87
>          4 Andere Rel.gemeinschaft |        881        3.90       69.76
>                  5  Konfessionslos |      6,837       30.24      100.00
> -----------------------------------+-----------------------------------
>                              Total |     22,611      100.00
> */
> 
> #delimit cr
delimiter now cr
. 
. rename tp1401 leis_eatdrink /* Essen oder trinken gehen (Café, Kneipe, Restaurant) */
r; t=0.00 11:35:20

. rename tp1402 leis_neighfriend /* Besuche Nachbarn,Freunde */
r; t=0.00 11:35:20

. rename tp1403 leis_famrel /* Besuche Familie,Verwandte */
r; t=0.00 11:35:20

. rename tp1407 leis_church /* Kirchgang, Besuch religioeser Veranstaltungen */
r; t=0.00 11:35:20

. 
. #delimit;
delimiter now ;
. sort persnr;
r; t=0.02 11:35:20

. save my_variables_2003.dta, replace;
file my_variables_2003.dta saved
r; t=0.00 11:35:20

. merge 1:1 persnr using my_ppfad.dta;

    Result                           # of obs.
    -----------------------------------------
    not matched                        36,699
        from master                     2,016  (_merge==1)
        from using                     34,683  (_merge==2)

    matched                            20,595  (_merge==3)
    -----------------------------------------
r; t=0.03 11:35:20

. tab _merge;

                 _merge |      Freq.     Percent        Cum.
------------------------+-----------------------------------
        master only (1) |      2,016        3.52        3.52
         using only (2) |     34,683       60.54       64.05
            matched (3) |     20,595       35.95      100.00
------------------------+-----------------------------------
                  Total |     57,294      100.00
r; t=0.00 11:35:20

. keep if _merge==3;
(36,699 observations deleted)
r; t=0.00 11:35:20

. drop _merge;
r; t=0.06 11:35:20

. /******************/
> /* missing values */
> /******************/
> 
> mvdecode _all, mv(-1);
       relig: 145 missing values generated
leis_eatdr~k: 36 missing values generated
leis_neigh~d: 82 missing values generated
 leis_famrel: 124 missing values generated
 leis_church: 128 missing values generated
r; t=0.07 11:35:20

. mvdecode _all, mv(-2);
r; t=0.05 11:35:20

. mvdecode _all, mv(-3);
r; t=0.05 11:35:20

. /*********************/
> /* some descriptives */
> /*********************/
> 
> # delimit cr
delimiter now cr
. 
. matrix emptyrow = J(1,6,.)
r; t=0.00 11:35:20

. matrix everyone = emptyrow
r; t=0.00 11:35:20

. matrix everyone_short = emptyrow
r; t=0.00 11:35:20

. 
. foreach activity in church famrel neighfriend eatdrink {
  2.   matrix everyone_`activity'_abs = J(3,6,.)
  3.   matrix everyone_`activity'_rel = J(3,6,.)
  4.   matrix emptyrow_`activity' = J(1,6,.)
  5.   recode leis_`activity' -1 = .
  6.   local rownum = 0
  7.     foreach relig in 2 1 5 {
  8.         local rownum = `rownum'+1
  9.     count if leis_`activity' != . & relig == `relig'
 10.         local total = r(N)
 11.     count if leis_`activity' == 1 & relig == `relig'
 12.         matrix everyone_`activity'_abs[`rownum', 1] = r(N)
 13.     count if leis_`activity' <= 2 & relig == `relig'
 14.         matrix everyone_`activity'_abs[`rownum', 2] = r(N)
 15.     count if leis_`activity' <= 3 & relig == `relig'
 16.         matrix everyone_`activity'_abs[`rownum', 3] = r(N)
 17.     count if leis_`activity' <= 4 & relig == `relig'
 18.         matrix everyone_`activity'_abs[`rownum', 4] = r(N)
 19.     count if leis_`activity' <= 5 & relig == `relig'
 20.         matrix everyone_`activity'_abs[`rownum', 5] = r(N)
 21.     count if leis_`activity' != . & relig == `relig'
 22.         matrix everyone_`activity'_abs[`rownum', 6] = r(N)
 23.         
.     matrix everyone_`activity'_rel[`rownum', 1] = everyone_`activity'_abs[`rownum', 1] / `total'
 24.     matrix everyone_`activity'_rel[`rownum', 2] = everyone_`activity'_abs[`rownum', 2] / `total'
 25.     matrix everyone_`activity'_rel[`rownum', 3] = everyone_`activity'_abs[`rownum', 3] / `total'
 26.     matrix everyone_`activity'_rel[`rownum', 4] = everyone_`activity'_abs[`rownum', 4] / `total'
 27.     matrix everyone_`activity'_rel[`rownum', 5] = everyone_`activity'_abs[`rownum', 5] / `total'
 28.     matrix everyone_`activity'_rel[`rownum', 6] = everyone_`activity'_abs[`rownum', 6]
 29.   }
 30.   
.   matrix rownames everyone_`activity'_rel = Protestant Catholic "No religion"
 31.   matrix rownames emptyrow_`activity' = "`activity'"
 32.   
. }
(leis_church: 0 changes made)
  6,790
  10
  329
  1,108
  4,218
  6,790
  6,790
  6,004
  35
  1,204
  2,118
  4,313
  6,004
  6,004
  6,189
  2
  16
  46
  472
  6,189
  6,189
(leis_famrel: 0 changes made)
  6,784
  547
  3,243
  5,354
  6,634
  6,784
  6,784
  6,002
  486
  3,037
  4,771
  5,862
  6,002
  6,002
  6,184
  326
  2,569
  4,600
  5,999
  6,184
  6,184
(leis_neighfriend: 0 changes made)
  6,787
  328
  3,203
  5,325
  6,573
  6,787
  6,787
  6,014
  271
  2,745
  4,660
  5,832
  6,014
  6,014
  6,203
  282
  2,552
  4,635
  6,016
  6,203
  6,203
(leis_eatdrink: 0 changes made)
  6,804
  83
  1,415
  3,466
  6,116
  6,804
  6,804
  6,029
  85
  1,457
  3,260
  5,443
  6,029
  6,029
  6,216
  82
  1,310
  3,085
  5,594
  6,216
  6,216
r; t=0.31 11:35:20

. 
. foreach activity in church famrel neighfriend eatdrink {
  2.   matrix everyone_short = everyone_short \ emptyrow_`activity' \ everyone_`activity'_rel
  3. }
r; t=0.00 11:35:20

. 
. matrix colnames everyone_short = Daily Weekly Monthly Less Never Obs
r; t=0.00 11:35:20

. matorder everyone_short, matrix(everyone_short) over ifcol(Weekly Monthly Obs)
r; t=0.00 11:35:20

. matrix everyone_short_tbl = everyone_short
r; t=0.00 11:35:20

. matrix list everyone_short_tbl

everyone_short_tbl[17,3]
                Weekly    Monthly        Obs
         r1          .          .          .
     church          .          .          .
 Protestant  .04845361  .16318115       6790
   Catholic  .20053298  .35276482       6004
No religion  .00258523  .00743254       6189
     famrel          .          .          .
 Protestant  .47803656  .78920991       6784
   Catholic    .505998   .7949017       6002
No religion  .41542691  .74385511       6184
neighfriend          .          .          .
 Protestant  .47193163  .78458818       6787
   Catholic  .45643499  .77485866       6014
No religion  .41141383  .74721909       6203
   eatdrink          .          .          .
 Protestant   .2079659  .50940623       6804
   Catholic  .24166528  .54071985       6029
No religion  .21074646  .49629987       6216
r; t=0.00 11:35:20

. 
. log close
      name:  <unnamed>
       log:  /Users/sascha/Dropbox/suicide/RESTAT_replication/gsoep-suicide-data-2003-restat.log
  log type:  text
 closed on:  22 Jul 2017, 11:35:20
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
